<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
use think\Response;
use app\common\exception\BusinessException;

const PHARMACY_STATUS_INIT = 1;
const PHARMACY_STATUS_PASS = 2;
const PHARMACY_STATUS_FAIL = 3;
const PHARMACY_STATUS_UNAUTHORIZED = 4;

const PHARMACY_LOCATION = 'pharmacy:location';

/**
 * 获取\think\response\Json对象实例
 * @param mixed   $data 返回的数据
 * @param integer $code 状态码
 * @param array   $header 头部
 * @param array   $options 参数
 * @return \think\response\Json
 */
function jsonResult($data = [], $message = 'success', $code = 200, $header = [], $options = [], $status = '')
{
    $result = [
        'code' => empty($status) ? $code : $status,
        'message' => $message,
        'data' => $data
    ];
    return Response::create($result, 'json', $code, $header, $options);
}

function throwBusinessException($message = '', $code = 500)
{
    throw new BusinessException($message, $code);
}